package com.lk.pet.customers.service;

import com.lk.pet.customers.repository.OwnerRepository;
import com.lk.pet.customers.model.Owner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class OwnerService {
    @Autowired
    private OwnerRepository ownerRepository;


    public List<Owner> findAll(){
        return ownerRepository.findAll();
    }

    public Optional<Owner> findById(Integer id){
        return (id == null || id <= 0) ? Optional.empty() :ownerRepository.findById(id);
    }

    public void removeById(Integer id){
        ownerRepository.deleteById(id);
    }

    public void save(Owner owner){
        ownerRepository.save(owner);
    }
}
